{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "8116ee9e",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-02-07T13:55:21.637323Z",
     "start_time": "2024-02-07T13:55:20.304107Z"
    }
   },
   "outputs": [],
   "source": [
    "from einops import rearrange\n",
    "from torchvision import transforms\n",
    "from PIL import Image\n",
    "\n",
    "transform = transforms.Compose(\n",
    "    [\n",
    "        transforms.Resize((224, 224)),\n",
    "#         transforms.RandomResizedCrop(224),\n",
    "#         transforms.RandomHorizontalFlip(),\n",
    "        transforms.ToTensor(),\n",
    "    ]\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "deff7797",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-02-08T12:24:38.743729Z",
     "start_time": "2024-02-08T12:24:38.591058Z"
    }
   },
   "outputs": [],
   "source": [
    "import numpy as np"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "58989dc8",
   "metadata": {},
   "source": [
    "## Image"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "cbbac838",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-02-07T14:02:25.305528Z",
     "start_time": "2024-02-07T14:02:25.298925Z"
    }
   },
   "outputs": [],
   "source": [
    "from PIL import Image"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "6894b6b4",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-02-07T14:02:39.646406Z",
     "start_time": "2024-02-07T14:02:39.626204Z"
    }
   },
   "outputs": [],
   "source": [
    "image = Image.open('../nn_basics/imgs/boo.jpg')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "b0185f3f",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-02-07T14:02:45.354535Z",
     "start_time": "2024-02-07T14:02:45.338394Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(1500, 1500)"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "image.size"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "5038a39a",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-02-07T14:23:11.461043Z",
     "start_time": "2024-02-07T14:23:11.450438Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'RGB'"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# channel\n",
    "\n",
    "# \"L\": 8位灰度图像。\n",
    "# \"RGB\": 24位真彩色图像（8位×3）。\n",
    "# \"RGBA\": 32位真彩色图像+透明通道（8位×4）。\n",
    "image.mode"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "d79e2cf3",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-02-08T12:24:10.167103Z",
     "start_time": "2024-02-08T12:24:10.128469Z"
    }
   },
   "outputs": [],
   "source": [
    "from PIL.Image import fromarray"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "0691c1d9",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.13"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
